$(function () {
    //上报统计
    getRecordData();
});

/**
 * 获取上报统计
 */
function getRecordData() {
    var url = ctx + "maindata";
    $.ajax({
        cache : true,
        type : "POST",
        url : url,
        async : false,
        error : function(request) {
            parent.layer.alert("Connection error");
        },
        success : function(data) {
            var days = data.days;
            var record_count_1 = data.record_count_1;
            var record_count_2 = data.record_count_2;
            var lineChart = echarts.init(document.getElementById("echarts-line-chart"));
            var lineoption = {
                tooltip: {
                    trigger: 'axis',
                    axisPointer: {
                        type: 'shadow'
                    }
                },
                grid: {
                    left: '3%',
                    right: '4%',
                    bottom: '3%',
                    containLabel: true
                },
                xAxis: {
                    type: 'value'

                },
                yAxis: {
                    type: 'category',
                    data: ['鑫盛源食品有限公司']
                },
                series: [
                    {

                        type: 'bar',
                        data: [20]
                    }
                ]
            };
            lineChart.setOption(lineoption);
            $(window).resize(lineChart.resize);

            var months = data.months;
            var record_month_1 = data.record_month_1;
            var record_month_2 = data.record_month_2;

            var barChart = echarts.init(document.getElementById("echarts-bar-chart"));
            var baroption = {
                tooltip: {
                    trigger: 'item'
                },
                legend: {
                    orient: 'vertical',
                    left: 'left'
                },
                series: [
                    {
                        name: 'Access From',
                        type: 'pie',
                        radius: ['40%', '70%'],

                        itemStyle: {
                            borderRadius: 10,
                            borderColor: '#fff',
                            borderWidth: 1
                        },
                        data: [
                            { value: 7, name: '一般隐患' },
                            { value: 1, name: '重大隐患' },
                        ],
                        emphasis: {
                            itemStyle: {
                                shadowBlur: 10,
                                shadowOffsetX: 0,
                                shadowColor: 'rgba(0, 0, 0, 0.5)'
                            }
                        }
                    }
                ]
            };
            barChart.setOption(baroption);
            window.onresize = barChart.resize;
        }
    });
}
